define([
    'zepto',
    'underscore',
    'backbone',
    "text!templates/client/wxSuccess.html",
    "wTools"

], function ($, _, Backbone, template) {
    return Backbone.View.extend({
        $el: $main,
        el: $main0,
        template: _.template(template),
        events: {

        },
        initialize: function () {
            $("#home").remove();
            $("#head").hide();
            $(".footer").hide();
            this.render(wData);
            if(wData.urlData.returnUrl!=undefined&&wData.urlData.returnUrl!=null&&wData.urlData.returnUrl!=""&&wData.urlData.returnUrl!='null'){
                var timeFiv = 3;
                $("#resultMsg").html("支付成功," + timeFiv + "s后自动返回");
                var IntervalNum = setInterval(function () {
                    timeFiv--;
                    if (timeFiv == 0) {
                        clearInterval(IntervalNum);
                        if(wData.urlData.returnUrl!=undefined&&wData.urlData.returnUrl!=null&&wData.urlData.returnUrl!="") {
                            location.href = wData.urlData.returnUrl;
                        }else{
                            $("#resultMsg").html("返回失败,请关闭此页");
                        }
                        //返回地址backURL;
                    } else {
                        $("#resultMsg").html("支付成功," + timeFiv + "s后自动返回");
                    }
                }, 1000);
            }
        },


        back: function () {
            //
        },
        render: function (data) {
            var html = this.template(data);
            this.$el.html(html);
        },
        destroy: function () {
            this.undelegateEvents();
            this.$el.html("");
            delete this;
        }
    });
});